<?php
require_once dirname ( __FILE__ ) . '/lib/PHPExcel.php';
require_once dirname ( __FILE__ ) . '/lib/PHPExcel/IOFactory.php';

if (isset($_FILES ["file"] ["name"])) {
    set_time_limit(0);
    $path = 'upload/'.$_FILES["file"]["name"];
    $flag = move_uploaded_file ( $_FILES ["file"] ["tmp_name"], $path);
    
    $reader = PHPExcel_IOFactory::createReader ( 'Excel5' );
    $PHPExcel = $reader->load($path);
    $sheet = $PHPExcel->getSheet(0);
    $highestRow = $sheet->getHighestRow();
    for($row = 0; $row <= $highestRow; $row++) {
        $pd_stock = array ();
        $prod = false;
        $val = (string)$sheet->getCellByColumnAndRow(0, $row)->getValue();
        echo $val;
    }
}

//$sheet = $PHPExcel->getSheet(1);
//$highestRow = $sheet->getHighestRow();
//for($row = 1; $row <= $highestRow; $row++) {
//	$pd_stock = array ();
//	$prod = false;
//	for($column = 0; $column <= 5; $column++) {
//		$val = $sheet->getCellByColumnAndRow($column, $row)->getValue();
//		switch ($column) {
//			case 0 :
//			    $val = (string)$val;
//			    $params = array(
//			        'Supplier'=>'productcenter',
//			        'BrandCode'=>$val
//			    );
//			    $prods = get_products_by_params($params);
//			    print_r(count($prods).'<br>');
//			    foreach ($prods as $prod) {
//			        echo $prod['_id'].':'.$prod['Stock'].' => Out of stock<br>';
//    			    set_product_field($prod['_id'], 'Stock', 'Out of stock');
//			    }
//				break;
//	        default:
//	            break;
//		}
//	}
//}
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" /> <br />
<input type="submit" name="submit" value="Submit" />
</form>
